package com.medical.admin.patient.controller;

import com.medical.admin.patient.common.dto.MedicalRecordDto;
import com.medical.admin.patient.service.MedicalRecordService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@Api(tags = "病历管理")
@RestController
@RequestMapping("/MedicalRecord")
public class MedicalRecordController {
    @Resource
    private MedicalRecordService medicalRecordService;

    @ApiOperation("查询病历信息")
    @GetMapping("/searchMedicalRecord")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<MedicalRecordDto> searchMedicalRecord(@NotNull Long patientId) {
        return ResponseEntity.success(medicalRecordService.searchMedicalRecord(patientId));
    }

    @ApiOperation("增加病历信息")
    @PostMapping("/addMedicalRecord")
    @ApiImplicitParam(name = "medicalRecordDto",value = "病历dto类")
    public ResponseEntity<Integer> addMedicalRecord(@NotNull @RequestBody MedicalRecordDto medicalRecordDto) {
        return ResponseEntity.success(medicalRecordService.addMedicalRecord(medicalRecordDto));
    }
    @ApiOperation("修改病历信息")
    @PutMapping("/modifyMedicalRecord")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<Integer> modifyMedicalRecord(@NotNull @RequestBody MedicalRecordDto medicalRecordDto) {
        return ResponseEntity.success(medicalRecordService.modifyMedicalRecord(medicalRecordDto));
    }

    @ApiOperation("删除病历信息")
    @DeleteMapping("/removeMedicalRecord")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<Integer> removeMedicalRecord(@NotNull Long patientId) {
        return ResponseEntity.success(medicalRecordService.removeMedicalRecord(patientId));
    }

}
